<?php

$container_bl=join('&nbsp;', $form->_button_container['BL']);
$container_br=join('&nbsp;', $form->_button_container['BR']);
$container_tr=join('&nbsp;', $form->_button_container['TR']);

if ($form->_status=='delete' || $form->_action=='delete' || $form->_status=='unknow_record'):
	echo $form->output;
else:

$campos=$form->template_details('itssal');
$scampos  ='<tr id="tr_itssal_<#i#>">';
$scampos .='<td class="littletablerow" align="left" >'.$campos['codigo']['field'].'</td>';
$scampos .='<td class="littletablerow" align="left" >'.$campos['itdescrip']['field'].'</td>';
$scampos .='<td class="littletablerow" align="right">'.$campos['cantidad']['field'].  '</td>';
$scampos .='<td class="littletablerow" align="right">'.$campos['costome']['field']. '</td>';
$scampos .='<td class="littletablerow" align="right">'.$campos['costomn']['field']. '</td>';
$scampos .= '<td class="littletablerow"><a href=# onclick="del_itssal(<#i#>);return false;">'.img("images/delete.jpg").'</a></td></tr>';
$campos=$form->js_escape($scampos);




if(isset($form->error_string)) echo '<div class="alert">'.$form->error_string.'</div>';

//echo $form_scripts;
echo $form_begin;
if($form->_status!='show'){ ?>

<script language="javascript" type="text/javascript">
var itssal_cont=<?php echo $form->max_rel_count['itssal']; ?>;

$(function(){
	$(".inputnum").numeric(".");
});
function add_itssal(){
	var htm = <?php echo $campos; ?>;
	can = itssal_cont.toString();
	con = (itssal_cont+1).toString();
	htm = htm.replace(/<#i#>/g,can);
	htm = htm.replace(/<#o#>/g,con);
	$("#__UTPL__").before(htm);
	$("#cantidad_"+can).numeric(".");
	itssal_cont=itssal_cont+1;
}
function del_itssal(id){
	id = id.toString();
	$('#tr_itssal_'+id).remove();
}
</script>
<?php } ?>
<table align='center' width="85%" style='background: #EEEEEE' >
	<tr>
<?php if ($form->_status=='show') { ?>
		<td>
			<a href="#" onclick="window.open('<?php echo base_url() ?>formatos/verhtml/SSAL/<?php echo $form->numero->value ?>', '_blank', 'width=800, height=600, scrollbars=Yes, status=Yes, resizable=Yes, screenx='+((screen.availWidth/2)-400)+',screeny='+((screen.availHeight/2)-300)+'');" heigth="600" ><img src='<?php echo base_url() ?>images/html_icon.gif'></a>
			<a href="#" onclick="window.open('<?php echo base_url() ?>formatos/ver/SSAL/<?php echo $form->numero->value ?>', '_blank', 'width=800, height=600, scrollbars=Yes, status=Yes, resizable=Yes, screenx='+((screen.availWidth/2)-400)+',screeny='+((screen.availHeight/2)-300)+'');" heigth="600" ><img src='<?php echo base_url() ?>images/pdf_logo.gif'></a> Comprobante  
		<td>
		 <?php } ?>
        <td width="45%" align="right"><?php echo $container_tr?><?php echo $container_br?></td>
	</tr>
</table>
<table align='center' width="80%">
	<tr>
		<td colspan='2'>
		<fieldset style='border: 2px outset #9AC8DA;background: #FFFFFF;'>
		<legend class="titulofieldset" style='color: #2E4B77;'>N&uacute;mero de Ajuste <b><?php if($form->_status=='show' or $form->_status=='modify' ) echo str_pad($form->numero->output,8,0,0); ?></b></th></legend>
		<table width="100%" style="margin: 0; width: 100%;">
			<tr>
				<td class="littletableheader"><?php echo $form->fecha->label;    ?>*&nbsp;</td>
				<td class="littletablerow">   <?php echo $form->fecha->output;   ?>&nbsp;</td>
				<td class="littletableheader"><?php echo $form->almacen->label;  ?>&nbsp;</td>
				<td class="littletablerow">   <?php echo $form->almacen->output,$form->caububides->output; ?>&nbsp;</td>
			</tr>
			<tr>
				<td class="littletableheader"><?php echo $form->tipo->label;  ?>&nbsp;</td>
				<td class="littletablerow">   <?php echo $form->tipo->output; ?>&nbsp;</td>
				<td class="littletableheader"><?php echo $form->descrip->label; ?>&nbsp;</td>
				<td class="littletablerow"   ><?php echo $form->descrip->output;   ?>&nbsp;</td>
			</tr>
			<tr>
				<td class="littletableheader"><?php echo $form->tipo_doc->label  ?>*&nbsp;</td>
				<td class="littletablerow">   <?php echo $form->tipo_doc->output ?>&nbsp;</td>
				<td class="littletableheader"><?php echo $form->motivo->label; ?>&nbsp;</td>
				<td class="littletablerow"   ><?php echo $form->motivo->output;   ?>&nbsp;</td>
			</tr>
			<tr>
				<td class="littletableheader"><?php echo $form->moneda->label;    ?>*&nbsp;</td>
				<td class="littletablerow">   <?php echo $form->moneda->output;   ?>&nbsp;</td>
				<td class="littletableheader"></td>
				<td class="littletablerow"></td>
			</tr>
			<tr>
				<td class="littletableheader"><?php echo $form->cambio->label;    ?>*&nbsp;</td>
				<td class="littletablerow">   <?php echo $form->cambio->output;   ?>&nbsp;</td>
				<td class="littletableheader"></td>
				<td class="littletablerow"></td>
			</tr>
		</table><br>
		</fieldset>
		</td>
	</tr>
	<tr>
		<td colspan='2'>
		<div style='overflow:auto;border: 1px solid #9AC8DA;background: #FAFAFA;height:250px'>
		<fieldset style='border: 2px outset #9AC8DA;background: #EFEFFF;'>
		<legend class="titulofieldset" style='color: #2E4B77;'>Lista de Art&iacute;culos</legend>
		<table width='90%' align='center'>
			<tr class="littletablerow">
				<td width='180' bgcolor='#527D9E' align='center'>C&oacute;digo</td>
				<td bgcolor='#527D9E'>Descripci&oacute;n</td>
				<td bgcolor='#527D9E'>Cantidad</td>
				<td bgcolor='#527D9E'>Costo ME</td>
				<td bgcolor='#527D9E'>Costo MN</td>
				<?php if($form->_status!='show') {?>
					<td class="littletableheader">&nbsp;</td>
				<?php } ?>
			</tr>

			<?php for($i=0;$i<$form->max_rel_count['itssal'];$i++) {
				$it_codigo    = "codigo_$i";
				$it_descrip   = "itdescrip_$i";
				$it_cant      = "cantidad_$i";
				$it_costome   = "costome_$i";
				$it_costomn   = "costomn_$i";
			?>

			<tr id='tr_itssal_<?php echo $i; ?>'>
				<td class="littletablerow" align="left" ><?php echo $form->$it_codigo->output; ?></td>
				<td class="littletablerow" align="left" ><?php echo $form->$it_descrip->output;  ?></td>
				<td class="littletablerow" align="right"><?php echo $form->$it_cant->output;   ?></td>
				<td class="littletablerow" align="right"><?php echo $form->$it_costome->output;  ?></td>
				<td class="littletablerow" align="right"><?php echo $form->$it_costomn->output;  ?></td>
				<?php if($form->_status!='show') {?>
				<td class="littletablerow">
					<a href='#' onclick='del_itssal(<?=$i ?>);return false;'><?php echo img("images/delete.jpg"); ?></a>
				</td>
				<?php } ?>
			</tr>
			<?php } ?>

			<tr id='__UTPL__'>
				<td id='cueca'></td>
			</tr>
		</table>
		<?php echo $container_bl ?>
		<?php echo $container_br ?>
		</td>
		</fieldset>
		</div>
		<?php echo $form_end; ?>
	</tr>
</table>
<?php endif; ?>
